package com.xnyzc.lhy.mis.controller.cmsapi.worksheet;

import com.xnyzc.lhy.common.entity.DiDiRv;
import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.penum.EErrorCode;
import com.xnyzc.lhy.mis.entity.param.worksheet.didi.CreateWorkOrderParam;
import com.xnyzc.lhy.mis.entity.param.worksheet.didi.UpdateWorkOrderParam;
import com.xnyzc.lhy.mis.entity.param.worksheet.didi.WorkOrderUrgentParam;
import com.xnyzc.lhy.mis.service.worksheet.IWorkOrderService;
import com.xnyzc.lhy.resource.entity.worksheet.param.heli.LoginSynchronousParam;
import com.xnyzc.lhy.resource.entity.worksheet.param.heli.RoleSynchronousParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 滴滴调用工单相关
 * </p>
 * @since 2019-10-08
 */
@RestController
@RequestMapping("oa/didi/workorder")
public class WorkOrderController {

    @Autowired
    private IWorkOrderService workOrderService;

    /**
     * 新建工单
     *
     * @param createWorkOrderParam
     * @return
     */
    @ApiOperation(value = "新建工单", notes = "新建工单")
    @PostMapping(value = "/getCreateWorkOrder")
    public DiDiRv getCreateWorkOrder(@ApiParam(name =
            "createWorkOrderParam", value = "新建工单") @RequestBody CreateWorkOrderParam createWorkOrderParam) {
        return workOrderService.getCreateWorkOrder(createWorkOrderParam);
    }

    /**
     * 更新工单接口
     *
     * @param updateWorkOrderParam
     * @return
     */
    @ApiOperation(value = "更新工单接口", notes = "更新工单接口")
    @PostMapping(value = "/getUpdateWorkOrder")
    public DiDiRv getUpdateWorkOrder(@ApiParam(name =
            "updateWorkOrderParam", value = "更新工单接口") @RequestBody UpdateWorkOrderParam updateWorkOrderParam) {
        return workOrderService.getUpdateWorkOrder(updateWorkOrderParam);
    }

    /**
     * 工单加急接口
     *
     * @return
     */
    @ApiOperation(value = "工单加急接口", notes = "工单加急接口")
    @PostMapping(value = "/getWorkOrderUrgent")
    public DiDiRv getWorkOrderUrgent(@RequestBody WorkOrderUrgentParam workOrderUrgentParam) {
        return workOrderService.getWorkOrderUrgent(workOrderUrgentParam);
    }

    /**
     * 登陆账号同步接口
     *
     * @return
     */
    @ApiOperation(value = "登陆账号同步接口", notes = "登陆账号同步接口")
    @PostMapping(value = "/getLoginSynchronous")
    public Rv getLoginSynchronous(@RequestBody LoginSynchronousParam loginSynchronousParam
    ) {
        try {
            return workOrderService.getLoginSynchronous(loginSynchronousParam);
        }catch (Exception ex){
            return Rv.error(EErrorCode.unkown);
        }
    }

    /**
     * 客服角色同步接口。
     *
     * @return
     */
    @ApiOperation(value = "客服角色同步接口", notes = "客服角色同步接口")
    @PostMapping(value = "/getRoleSynchronous")
    public Rv getRoleSynchronous(@RequestBody RoleSynchronousParam roleSynchronousParam
    ) {
        try {
            return workOrderService.getRoleSynchronous(roleSynchronousParam);
        }catch (Exception ex){
            return Rv.error(EErrorCode.unkown);
        }
    }

}
